const CryptoJS = require('crypto-js');  //引入crypto-js
const MKEY = "0123456789abcdef"
const MIV = "9c35ddewqtyuikjh"
// import userPb from '@/common/proto/user_pb.js';
//解密方法AES
function DecryptAES(word) {
	let vkey = CryptoJS.enc.Utf8.parse(MKEY); //传入的秘钥
	let viv = CryptoJS.enc.Utf8.parse(MIV); //传入的秘钥偏移量
    let decrypt = CryptoJS.AES.decrypt(word, vkey, { iv: viv, padding: CryptoJS.pad.Pkcs7 });
    let decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
    return decryptedStr.toString();
}
//加密方法AES
function EncryptAES(word) {
	let vkey = CryptoJS.enc.Utf8.parse(MKEY); //传入的秘钥
	let viv = CryptoJS.enc.Utf8.parse(MIV); //传入的秘钥偏移量
    let encrypted = CryptoJS.AES.encrypt(word, vkey, { iv: viv, padding: CryptoJS.pad.Pkcs7 });
    return encrypted.toString();
}

export default {
	EncryptAES,
	DecryptAES
}